var AMSELCET = AMSELCET || {};

AMSELCET.formatRowsByGroup = function (gname, payload, key) {
    var rows = payload["rows"]
    var logMap = {}
    var options = []
    for (i = 0; i < rows.length; i++) {
        r = rows[i]
        if (!logMap[r[gname]]) {
            var tmp = {name: r[gname], children: [r]}
            options.push(tmp)
            logMap[r[gname]] = tmp
        } else {
            logMap[r[gname]].children.push(r)
        }
    }
    payload[key] = options
    return payload
}